package com.atguigu.springcloud.config;

/**
 * @author xiangdd
 * @since 2021/12/17
 */

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Gateway网关路由配置类
 */


@Configuration
public class GatewayConfig {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder){
        RouteLocatorBuilder.Builder routes = builder.routes();
        routes.route("path_route_atguigu",
                r-> r.path("/guonei")
                   .uri("http://news.baidu.com/guonei"))
                .build();
        return routes.build();
    }
}
